package com.zb.xtzh.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zb.xtzh.service.XtzhService;
import com.zhibang.comnom.domain.Xtzh;
import com.zhibang.comnom.re.Result;
import com.zhibang.comnom.re.ResultCode;
import com.zhibang.comnom.vo.UpdXtzh;
import com.zhibang.comnom.vo.XtzhVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/xtzh")
@CrossOrigin
@Api(tags = "系统账号信息",value = "查询系统账号")
public class XtzhController {

    @Resource
    private XtzhService xtzhServiceImpl;

    @ApiOperation(value = "查询系统账号",notes = "查所有系统账号",httpMethod = "GET")
    @RequestMapping(value = "finda",method = RequestMethod.GET)
    public Result findXtzh(String searchParams)throws Exception{
        ObjectMapper mapper = new ObjectMapper();
        XtzhVo xtzhVo = null;
        if(searchParams!=null){
            xtzhVo = mapper.readValue(searchParams, XtzhVo.class);
            System.out.println(xtzhVo);
        }
        List<Xtzh> xtzhs = xtzhServiceImpl.queryXtzh(xtzhVo);
        System.out.println(xtzhs);
        return Result.ok(ResultCode.SUCCESS,xtzhs);

    }

//    @ApiOperation(value = "修改系统账号",notes = "修改系统账号信息",httpMethod = "POST")
//    @RequestMapping(value ="upd",method = RequestMethod.POST)
//    public Result updateXtzh(UpdXtzh updXtzh)throws Exception{
//        int i = xtzhServiceImpl.updXtzh(updXtzh);
//        System.out.println(i);
//        return Result.ok(ResultCode.SUCCESS,i);
//    }

}
